package com.huangguolin.cloud.share.service.impl;

import com.huangguolin.cloud.mybatis.entity.PtShareEntity;
import com.huangguolin.cloud.mybatis.flexigrid.PadingRstEntity;
import com.huangguolin.cloud.mybatis.flexigrid.PagingEntity;
import com.huangguolin.cloud.role.entity.SearchRoleEntity;
import com.huangguolin.cloud.share.repository.ShareDao;
import com.huangguolin.cloud.share.service.ShareService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ShareServiceImpl implements ShareService {
        @Resource
        private ShareDao shareDao;

        @Override
        public PadingRstEntity<PtShareEntity> queryShareListByPage(SearchRoleEntity search, PagingEntity paging) {

                paging.dealColums(PtShareEntity.class);
                PadingRstEntity<PtShareEntity> ptShareEntityPadingRstEntity = new PadingRstEntity<>();
                ptShareEntityPadingRstEntity.setPage(paging.getPage());
                //search.deal();
                List<PtShareEntity> list = shareDao.queryShareListByPage(search,paging);
                Integer total = shareDao.queryShareTotal(search);
                ptShareEntityPadingRstEntity.setRawRecords(list);
                ptShareEntityPadingRstEntity.setTotal(total);
                ptShareEntityPadingRstEntity.putItem();
                return ptShareEntityPadingRstEntity;

        }

        @Override
        public void deleteFile(String fileUuid) {
                shareDao.deleteFile(fileUuid);
        }
}
